Division Algorithms

รท โš™๏ธ ๐Ÿ’ป

Systematic Procedures for Efficient Computation

10000 รท 100 = 100
(16) รท (4) = (4)
1/10

Definition

A division algorithm is a systematic procedure for dividing one number (dividend) by another (divisor) to produce a quotient and a remainder.

In computer systems, division must be implemented efficiently in hardware (ALUs, CPUs) or software (compilers, arithmetic libraries).

โš™๏ธ

Hardware

Implemented in ALUs and CPUs for fast computation

๐Ÿ’ป

Software

Used in compilers and arithmetic libraries

2/10

Basic Steps in Division Algorithms

Almost all division algorithms (binary or decimal) follow these steps:

1

Initialization

Load dividend, divisor, quotient, remainder.

2

Align

Shift dividend/divisor to align significant bits.

3

Subtract / Add

Subtract divisor from dividend portion.

4

Test Result

If subtraction โ‰ฅ 0 โ†’ keep result, else restore or adjust.

5

Quotient Update

Set quotient bit (1 or 0) depending on test.

6

Remainder Update

Store updated remainder.

7

Repeat

Repeat until all dividend bits are processed.

3/10

Types of Division Algorithms

๐Ÿ”ข

Binary Division

Basic shift and subtract method

๐Ÿ”„

Restoring Division

Restores when remainder becomes negative

โšก

Non-Restoring Division

Avoids restore step, faster

๐Ÿ“Š

SRT Division

Uses lookup table, modern CPUs

๐Ÿ”„

Goldschmidt Division

Based on reciprocal approximation

4/10

Binary Division

Works like long division in decimal, but with binary numbers (0 and 1). Uses shift and subtract method.

๐Ÿ”

Compare

โ†’
โž–

Subtract

โ†’
๐Ÿ“

Set Quotient Bit

โ†’
โฌ‡๏ธ

Bring Down Next Bit

1

Compare

Compare divisor with dividend (or partial dividend).

2

Subtract

If divisor โ‰ค partial dividend โ†’ subtract โ†’ quotient bit = 1.

3

Set Quotient Bit

Else โ†’ quotient bit = 0.

4

Repeat

Bring down next bit of dividend and repeat.

๐Ÿ“Œ Example: Divide 16 รท 4 โ†’ in binary: 10000 รท 100.

10000 รท 100 = 100
(16) รท (4) = (4)
Quotient = 100 (4 in decimal).
Remainder = 0.
5/10

Restoring Division Algorithm

Used for signed numbers. If subtraction makes the remainder negative, the original value is restored.

1

Load

Load dividend & divisor.

2

Subtract

Subtract divisor from partial dividend.

3

Test

If result โ‰ฅ 0 โ†’ quotient bit = 1.

4

Restore

If result < 0 โ†’ restore value (add divisor back), quotient bit = 0.

5

Shift

Shift remainder left and bring down next bit.

6

Repeat

Repeat until all bits processed.

โœ…

Advantage

Simple and systematic

โŒ

Disadvantage

Slow (extra "restore" step)

6/10

Non-Restoring Division Algorithm

Improvement over restoring division. Avoids the restore step โ†’ instead adjusts in next iteration.

โž–

Subtract

โ†’
๐Ÿ”

Test Result

โ†’
๐Ÿ“

Set Quotient Bit

โ†’
โšก

Adjust Next Step

1

Subtract

Subtract divisor from partial dividend.

2

Test & Set

If result โ‰ฅ 0 โ†’ quotient bit = 1, continue subtracting.

3

Adjust

If result < 0 โ†’ quotient bit = 0, add divisor in next step (instead of restoring immediately).

4

Correct

At the end, if remainder is negative, perform one correction (add divisor).

โœ…

Advantage

Faster than restoring division

โŒ

Disadvantage

Slightly more complex control logic

7/10

SRT Division Algorithm

Used in modern CPUs. Uses a lookup table to decide quotient digits (not just 0 or 1, but also -1, 0, +1).

๐Ÿ“Š

Lookup Table

โ†’
๐Ÿ”ข

Quotient Digit

โ†’
โš–๏ธ

Operation

โ†’
๐Ÿ”„

Update

1

Initialize

Initialize dividend, divisor.

2

Lookup

Use lookup table โ†’ decide next quotient digit based on remainder/divisor ratio.

3

Perform

Perform subtraction or addition accordingly.

4

Update

Update quotient and remainder.

5

Repeat

Repeat until all bits processed.

โœ…

Advantage

Very fast, suitable for floating-point division in processors

โŒ

Disadvantage

Complex hardware design

8/10

Goldschmidt Division Algorithm

Based on reciprocal approximation: Instead of directly dividing, it repeatedly multiplies both dividend and divisor by an approximation factor until divisor โ‰ˆ 1.

๐Ÿ“

Normalize

โ†’
โœ–๏ธ

Multiply Both

โ†’
๐Ÿ”„

Repeat

โ†’
๐Ÿ“Š

Result

1

Normalize

Normalize divisor so it approaches 1.

2

Multiply

Multiply both dividend & divisor by scaling factors.

3

Repeat

Repeat until divisor โ‰ˆ 1.

4

Result

Dividend value โ†’ quotient.

โœ…

Advantage

Efficient for parallel hardware implementation

๐Ÿ’ป

Use Case

Floating-point units (FPUs), GPUs

9/10

Comparison and Summary

Algorithm Signed? Speed Complexity Used In
Binary Division Unsigned Slow Simple Basic ALUs, teaching
Restoring Division Signed Moderate Simple Early CPUs
Non-Restoring Division Signed Faster Moderate CPUs before SRT
SRT Division Signed Very Fast Complex Modern CPUs, FPUs
Goldschmidt Division Signed Very Fast Complex (parallel multipliers needed) GPUs, floating-point
  • Binary Division โ†’ Basic, shift & subtract
  • Restoring Division โ†’ Restores when negative โ†’ slower
  • Non-Restoring Division โ†’ No restore step โ†’ faster
  • SRT Division โ†’ Uses lookup table, efficient for high-speed CPUs
  • Goldschmidt Division โ†’ Parallel multiplication-based, used in floating-point arithmetic
10/10